#include <stdlib.h>
#include <string.h>
#include "game_entities.h"

Skill *create_skill(const char *name, int cost, void (*cast_func)(Skill *))
{
    Skill *new_skill = (Skill *)malloc(sizeof(Skill));
    new_skill->name = strdup(name); // 动态分配内存保存技能名称
    new_skill->cost = cost;
    new_skill->cast = cast_func; // 设置技能的释放函数
    return new_skill;
}

void destroy_skill(Skill *skill)
{
    if (skill)
    {
        free(skill->name); // 释放技能名称的内存
        free(skill);       // 释放技能结构体的内存
    }
}
